package com.jeesite.modules.ic.service;

import com.jeesite.modules.ic.dao.IcCardDao;
import com.jeesite.modules.ic.dao.IcUserDao;
import com.jeesite.modules.ic.entity.IcCard;
import com.jeesite.modules.ic.entity.IcUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserDataService {

    @Autowired
    private IcCardDao icCardDao;

    @Autowired
    private IcUserDao icUserDao;

    public void synUser(String uid){
        IcUser icUser = new IcUser();
        icUser.setId(uid);
        icUser = icUserDao.get(icUser);
        if(icUser!=null){
            //卡数量
            IcCard icCard = new IcCard();
            icCard.setUserId(uid);
            long count = icCardDao.findCount(icCard);
            icUser.setCardNum(Long.valueOf(count).intValue());

            icUserDao.update(icUser);
        }
    }
}
